package pl.mw.cmd.internal.executor.time;

import java.util.Date;

import pl.mw.cmd.executor.CommandExecutor;
import pl.mw.cmd.executor.ResultWriter;

/**
 * Implementacja {@link CommandExecutor} ktora pokazuje czas.
 */
public class TimeExecutor implements CommandExecutor {
	
	public TimeExecutor() {
		System.out.println("[pl.mw.cmd.executor.time] [TimeExecutor] Component created.");
	}

	/**
	 * Startuje parser.
	 */
	public void start() {
		System.out.println("[pl.mw.cmd.executor.time] [TimeExecutor] Component activated.");
	}

	/**
	 * Zatrzymuje parser.
	 */
	public void stop() {
		System.out.println("[pl.mw.cmd.executor.time] [TimeExecutor] Component deactivated.");
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see CommandExecutor#execute(String[], ResultWriter)
	 */
	@Override
	public void execute(String[] args, ResultWriter resultWriter) {
		
		if (args.length != 0) {
			resultWriter.write("Nieprawidlowa liczba argumentow.\r\n> ");
		} else {
			resultWriter.write(new Date().toString() + "\r\n> ");
		}
	}
}
